﻿@*<div class="page-quote">
    <blockquote class="layui-elem-quote">登录记录列表</blockquote>
</div>*@
<div class="page-list">
    <table id="tableLoginLog" lay-filter="tableList"></table>
</div>

<script>
    var LogRecord = function () {
        let inited = false;
        let data = {};
        var table;

        function initData() {
            layui.use(['form', 'layer', 'table', 'element', 'laydate'], function () {

                //加载数据
                loadData();

            });

        }

        function loadData() {
            var data = $('#formQueryLoginLog').serializeJson();

            layui.table.render({
                elem: '#tableLoginLog'
                , height: 670
                , url: '/Person/GetLoginRecordList' //数据接口
                , where: ""
                , page: true //开启分页
                , limit: 15
                , cols: [[ //表头
                    //{ field: 'id', title: 'ID', width: 100, sort: true }
                    {
                        field: 'id', title: '登录记录', templet: function (d) {
                            var txt = layui.util.toDateString(d.loginTime, "[yyyy-MM-dd HH:mm:ss]");
                            if (d.loginStatus == 1) {
                                txt += '&nbsp;&nbsp;<span class="tip-green">登录成功</span>';
                            }
                            else if (d.loginStatus == 2) {
                                txt += '&nbsp;&nbsp;<span class="tip-red">登录失败</span>';
                            }
                            txt += " (" + d.ip + "," + d.userAgent + ")";
                            return txt;
                        }
                    }
                    //{
                    //    field: 'loginTime', title: '登录时间', templet: function (d) {
                    //        return layui.util.toDateString(d.loginTime, "yyyy-MM-dd HH:mm:ss");
                    //    }, width: 160
                    //}
                    //, { field: 'ip', title: 'IP', width: 160 }
                    //, { field: 'userAgent', title: 'UserAgent' }
                    //, {
                    //    field: 'loginStatusText', title: '类型', width: 160, templet: function (d) {
                    //        if (d.loginStatus == 1) {
                    //            return '<span class="tip-green">成功</span>';
                    //        }
                    //        else if (d.loginStatus == 2) {
                    //            return '<span class="tip-red">失败</span>';
                    //        }
                    //        return d.loginStatusText;
                    //    }
                    //}
                    
                    //, { field: '', title: '操作', width: 150, align: 'center', toolbar: '#barTool' }
                ]]
                , done: function (res, curr, count) {//请求数据完成时，关闭加载loading
                    console.log(res);
                }

            });


        }

        return {
            init() {//初始化
                if (!inited) {
                    initData();
                    inited = true;
                }
            }
        };
    }();
</script>
